// src/api/mealRecord.js
import axios from 'axios'

/**
 * 获取所有用餐记录
 * @returns {Promise<MealRecord[]>}
 */
export function listMealRecords() {
    return axios.get('/mealRecord/list')
}

/**
 * 根据 ID 获取单条用餐记录
 * @param {number|string} id 记录 ID
 * @returns {Promise<MealRecord>}
 */
export function getMealRecord(id) {
    return axios.get(`/mealRecord/${id}`)
}

/**
 * 获取所有客户的用餐信息汇总
 * @returns {Promise<ClientMealInfo[]>}
 */
export function listAllClientMealInfo(params = {}) {
    return axios.get('/mealRecord/listAllClientMeal', { params })
}

export function listByClient(params) {
    return axios.get('/mealRecord/byClient', { params })
}
/**
 * 创建新的用餐记录
 * @param {Object} record MealRecord 对象，示例字段：{ clientId, calendarId, mealTime, status, … }
 * @returns {Promise<void>}
 */
export function createMealRecord(record) {
    return axios.post('/mealRecord/create', record)
}

/**
 * 更新已有的用餐记录
 * @param {Object} record MealRecord 对象，必须带 id，例如：{ id, clientId, calendarId, mealTime, status, … }
 * @returns {Promise<void>}
 */
export function updateMealRecord(record) {
    return axios.put('/mealRecord/update', record)
}

/**
 * 删除用餐记录
 * @param {number|string} id 记录 ID
 * @returns {Promise<void>}
 */
export function deleteMealRecord(id) {
    return axios.delete(`/mealRecord/delete/${id}`)
}
